<?php /* Smarty version 2.6.12, created on 2011-07-23 14:47:49
         compiled from analysis_import_csv.html */ ?>
<body>
<?php echo $this->_tpl_vars['xajax_scripts']; ?>
 
<form method='post' onsubmit='return check_form_pass();'>
<input type='hidden' name='op' value='import_file'>
<div class=form_title><?php echo @MI_IMPORT_DATA; ?>
</div>
  <br>
  <table width="50%" border='1'  align=center cellpadding='1' cellspacing="1" class='form_detail' cellspan='0'>
    <script>

function checkIsValidDate(str)
{
  if (str == "")
     return true;
  var pattern = /^(\d{4})\-(\d{1,2})\-(\d{1,2})$/g;
  if(!pattern.test(str))
     return false;
  var arrDate = str.split("-");
  if(parseInt(arrDate[0],10) < 100)
     arrDate[0] = 2000 + parseInt(arrDate[0],10) + "";
  var date = new Date(arrDate[0],(parseInt(arrDate[1],10) -1)+"",arrDate[2]);
  if(date.getYear() == arrDate[0]
     && date.getMonth() == (parseInt(arrDate[1],10)-1)+""
     && date.getDate() == arrDate[2])
     return true;
  else
     return false;
}

function do_add_lot(auto_focus)
{
    new_lot_no = document.getElementById("custom_add_lot_no").value;
    new_lot_expires = document.getElementById("custom_add_lot_expires").value;
    new_lot_expires = new_lot_expires.replace(/\//g, "-");

    if (new_lot_no == '' || new_lot_expires == '')
    {
        alert('<?php echo @MI_REQUIRE_LOT_DATA; ?>
');
        return false;
    }

    if (!checkIsValidDate(new_lot_expires))
    {
        alert('<?php echo @MI_INVALID_DATETIME_FORMAT; ?>
');
        return false;
    }

    for (var i=0; i<document.getElementById('lot_no').options.length; i++)
        if (document.getElementById('lot_no').options[i].innerText.replace(/\s-\s.*/, "") == new_lot_no)
        {
            document.getElementById('lot_no').selectedIndex = i;
            hide_add_lot(auto_focus);
            return true;
        }

    var objOption = new Option(new_lot_no + ' / <?php echo @MI_KIT_LOT_EXPIRES; ?>
 ' + new_lot_expires);
    document.getElementById('lot_no').options.add(objOption, 1);

    document.getElementById('lot_no').selectedIndex = 1;
    hide_add_lot(auto_focus);

    return true;
}

function show_add_lot(auto_focus)
{
    document.getElementById("custom_add_lot_no").value = '';
    document.getElementById("custom_add_lot_expires").value = '';
    document.getElementById("list_lot_block").style.display = 'none';
    document.getElementById("add_lot_block").style.display = '';
    if (auto_focus == true)
        document.getElementById("custom_add_lot_no").focus();
}

function hide_add_lot(auto_focus)
{
    document.getElementById("add_lot_block").style.display = 'none';
    document.getElementById("list_lot_block").style.display = '';
    if (auto_focus == true)
        document.getElementById('lot_no').focus();
}

function ServerSync_RefreshLotList()
{
    if (document.getElementById("kit_id").value != '')
        xajax_Ajax_RefreshLotList(document.getElementById("kit_id").value);
}

function check_form_pass()
{
    if (document.getElementById("add_lot_block").style.display == '')
    {
        if (document.getElementById("custom_add_lot_no").value != '')
        {
            if (!do_add_lot())
                return false;
        }
        else
            hide_add_lot();
    }

    if (document.getElementById('imp_csv_file').value == '' &&
        document.getElementById('imp_csv_folder').value == '')
    {
        alert('<?php echo @MI_ERROR_REQUIRE_IMPORT_SOURCE; ?>
');
        return false;
    }

    return true;
}

</script>
    <tr bordercolor="#cbe5f6"> 
      <td></td>
      <td><input type='checkbox' style='cursor: pointer;' name='analysis_screen_first' value='import_csv' <?php if ($this->_tpl_vars['analysis_screen_first'] == 'import_csv'): ?>checked <?php endif; ?> onclick='if (this.checked) 
        { location.href="/analysis.php?op=display_import_csv&analysis_screen_first=import_csv"; 
        } else { location.href="/analysis.php?op=display_import_csv&analysis_screen_first=analysis"; 
        }'><?php echo @MI_IMPORT_SCREEN_CSV_FIRST; ?>
</td>
    </tr>
    <tr bordercolor="#cbe5f6"> 
      <th><?php echo @MI_SELECT_KIT_ID; ?>
</th>
      <td> 
        <select name='kit_id' onchange='location.href="/analysis.php?op=display_import_csv&kit_id="+this.value;'><?php $_from = $this->_tpl_vars['kit_id_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['kit_id'] => $this->_tpl_vars['kit_desc']):
?> <option value='<?php echo $this->_tpl_vars['kit_id']; ?>
'<?php if ($this->_tpl_vars['kit_id'] == $this->_tpl_vars['current_kit_id']): ?> selected<?php endif; ?>><?php echo $this->_tpl_vars['kit_id']; ?>
 - <?php echo $this->_tpl_vars['kit_desc']; ?>
</option> <?php endforeach; endif; unset($_from); ?> 
        </select></td>
    </tr>
    <tr bordercolor="#cbe5f6"> 
      <th><?php echo @MI_KIT_LOT_NO; ?>
</th>
      <td> 
        <div id='list_lot_block'>
          <select name='lot_no'>
            <option></option><?php $_from = $this->_tpl_vars['lot_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['line']):
?>
            <option<?php if ($this->_tpl_vars['lot_no'] == $this->_tpl_vars['line']['lot_no']): ?> selected<?php endif; ?>><?php echo $this->_tpl_vars['line']['lot_no']; ?>
 / <?php echo @MI_KIT_LOT_EXPIRES; ?>
 <?php echo $this->_tpl_vars['line']['lot_expires']; ?>
</option> <?php endforeach; endif; unset($_from); ?> 
          </select>
          <input type='button' class='sbutton' value="&nbsp;<?php echo @MI_ADD_LOT; ?>
&nbsp;" onclick='show_add_lot(true);'>
        </div>
        <div id='add_lot_block' style='display:none;'>
          <input size=20 maxlength=200 name='custom_add_lot_no' value=''>
          &nbsp;<?php echo @MI_KIT_LOT_EXPIRES; ?>

          <input size=10 maxlength=10 name='custom_add_lot_expires' value=''>
          &nbsp; 
          <input type='button' class='sbutton' value="&nbsp;<?php echo @_ADD; ?>
&nbsp;" onclick='do_add_lot(true);'>
          <input type='button' class='sbutton' value="&nbsp;<?php echo @_CANCEL; ?>
&nbsp;" onclick='hide_add_lot(true);'>
        </div></td>
    </tr>
    <tr bordercolor="#cbe5f6"> 
      <th><?php echo @MI_SAMPLE_CSV_FILE; ?>
</th>
      <td> <?php if ($this->_tpl_vars['is_use_wab_console'] == true): ?> 
        <input type='text' style='cursor: pointer;' id='imp_csv_file' size="60" name='imp_csv_file' onclick='xajax_Ajax_SelectFile("Sample CSV", "CSV Files(*.csv)|*.csv", "imp_csv_file");'> 
        <?php else: ?> <input type='file' style='cursor: pointer;' name='imp_csv_file' size="60" /> 
        <?php endif; ?></td>
    </tr>
    <?php if ($this->_tpl_vars['is_use_wab_console'] == true): ?> 
    <tr bordercolor="#cbe5f6"> 
      <th><?php echo @MI_SAMPLE_CSV_FOLDER; ?>
</th>
      <td> 
        <input type='text' style='cursor: pointer;' id='imp_csv_folder' size="60" name='imp_csv_folder' onclick='xajax_Ajax_SelectFolder("Sample CSV Folder", "imp_csv_folder");'></td>
    </tr>
    <?php endif; ?> 
  </table>  <br>
  <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td align="center">
<input name="submit" type='submit' class='btn_import' value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo @MI_IMPORT; ?>
&nbsp;" /> 
        <input name="button" type='button' class='btn_uppage' onClick='location.href="/analysis.php?op=display";' value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo @MI_DISPLAY_INPUT; ?>
&nbsp;" /></td>
    </tr>
  </table>
</form>
<script>
  document.getElementById('kit_id').focus();
</script>